#pragma once

#include "Ent.h"
#include "Plane.h"
#include <osg/Geometry>

class JsonReader;

enum class UCSKind { XOY, YOZ, ZOX };

struct UcsPrivate;
class UCS : public Ent, public Plane
{
	Q_OBJECT
public:
	UCS(INode* parent);
	void setKind(UCSKind kind);
	UCSKind getKind() const;
	bool setAxis(const osg::Vec3d& x, const osg::Vec3d& y);

	virtual void save(QJsonObject &json) const;
	virtual void load(const QJsonObject& json, JsonReader& reader);
	virtual osg::Node* getRep3D() const override;
	virtual void addChild(const std::shared_ptr<INode>& pChild);
	virtual void removeChild(const std::shared_ptr<INode>& pChild);
	void removeChildren();
	const std::set<std::shared_ptr<INode>>& getChildren() const;
	void update3D();
	void updateMesh(const osg::Vec4& color, double gridLen, int minXI, int maxXI, int minYI, int maxYI);
	osg::Geometry* getMesh() const;

	virtual void visitChildren(INodeCallback lcb, bool preorder) const;
	virtual bool isLeaf() const;
	osg::Vec4 getUCSColor() const;
	void UCS::buildXPoints();
	std::vector<osg::Vec2d> getXPoints();
	void pauseBuildXPoints();
	void restoreBuildXPoints();

protected:
	UcsPrivate*	d_ptr;
};
